<!DOCTYPE html>
<html><head>
        <meta charset="utf-8">
    <title>童老师ThinkPHP交流群：484519446</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__admin__/style/bootstrap.css" rel="stylesheet">
    <link href="__admin__/style/font-awesome.css" rel="stylesheet">
    <link href="__admin__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__admin__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__admin__/style/demo.css" rel="stylesheet">
    <link href="__admin__/style/typicons.css" rel="stylesheet">
    <link href="__admin__/style/animate.css" rel="stylesheet">
    
</head>
<body>
    <!-- 头部 -->
    {include file="common/top"}
    <!-- /头部 -->
    
    <div class="main-container container-fluid">
        <div class="page-container">
            <!-- Page Sidebar -->
            {include file="common/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('Index/index')}">系统</a>
                    </li>
                                        <li>
                        <a href="{:url('Category/lst')}">商品分类管理</a>
                    </li>
                                        <li class="active">修改商品分类</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header bordered-bottom bordered-blue">
                <span class="widget-caption">修改商品分类</span>
            </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$Categorys.id}">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">上级分类</label>
                            <div class="col-sm-6">
                                <select name="pid">
                                    <option value="0">顶级分类</option>
                                    {volist name="CategoryRes" id="cate"}
                                    <option {if condition="$Categorys['pid'] eq $cate['id']"} selected="selected" {/if} value="{$cate.id}"><?php echo str_repeat('-', $cate['level']*8)?>{$cate.cate_name}</option>
                                    {/volist}
                                </select>
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">分类名称</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="cate_name" required="" value="{$Categorys.cate_name}" type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">icon图标</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="iconfont" value="{$Categorys.iconfont}" type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">推荐位</label>
                            <div class="col-sm-6">
                                <div class="checkbox">
                                {volist name="categoryRecposRes" id="recpos"}
                                    <label style="margin-right:15px;">
                                    <?php
                                        if(in_array($recpos['id'], $myCategoryRecposRes)){
                                            $checked='checked="checked"';
                                        }else{
                                            $checked='';
                                        }
                                    ?>
                                        <input <?php echo $checked;?> type="checkbox" name="recpos[]" value="{$recpos.id}" class="colored-blue">
                                        <span class="text">{$recpos.rec_name}</span>
                                    </label>
                                {/volist}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">价格区间数</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" value="{$Categorys.ps_num}" name="ps_num" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">筛选属性</label>
                            <div class="col-sm-6">
                                <?php 
                                if($searchAttrArr):
                                foreach ($searchAttrArr as $k => $v):
                                    if($k == 0){
                                        $opt = '[+]';
                                    }else{
                                        $opt = '[-]';
                                    }
                                ?>
                                <div class="radio">
                                    <a href="javascript:;" onclick="add(this);">{$opt}</a>
                                    <select name="type_id[]">
                                        <option value="">请选择</option>
                                        
                                        {volist name="typeRes" id="type"}
                                        <?php
                                            if($type['id'] == $v['type_id']){
                                                $selected = 'selected="selected"';
                                            }else{
                                                $selected = '';
                                            }
                                        ?>
                                        <option {$selected} value="{$type.id}">{$type.type_name}</option>
                                        {/volist}
                                    </select>
                                    <select attr_id = "{$v.id}" name="attr_id[]">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                                <?php endforeach; else:?>
                                <div class="radio">
                                    <a href="javascript:;" onclick="add(this);">[+]</a>
                                    <select name="type_id[]">
                                        <option value="">请选择</option>
                                        {volist name="typeRes" id="type"}
                                        <option value="{$type.id}">{$type.type_name}</option>
                                        {/volist}
                                    </select>
                                    <select name="attr_id[]">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            <?php endif;?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">显示到导航</label>
                            <div class="col-sm-6">
                                <div class="radio" style="float:left; padding-right:10px;">
                                    <label>
                                        <input name="show_cate" value="1" {if condition="$Categorys['show_cate'] eq 1"} checked="checked" {/if} class="colored-blue" type="radio">
                                        <span class="text">是</span>
                                    </label>
                                </div>
                                <div class="radio" style="float:left;">
                                    <label>
                                        <input name="show_cate" value="0" {if condition="$Categorys['show_cate'] eq 0"} checked="checked" {/if} class="colored-blue" type="radio">
                                        <span class="text">否</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">缩略图</label>
                            <div class="col-sm-6">
                                <input placeholder="" name="cate_img" type="file">
                                {if condition="$Categorys['cate_img']"}
                                <img src="__uploads__/{$Categorys.cate_img}" height="30">
                                {else /}
                                暂无缩略图
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">关键词</label>
                            <div class="col-sm-6">
                                <textarea class="form-control" name="keywords">{$Categorys.keywords}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">描述</label>
                            <div class="col-sm-6">
                                <textarea class="form-control" name="description">{$Categorys.description}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">保存信息</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
        </div>  
    </div>

        <!--Basic Scripts-->
    <script src="__admin__/style/jquery_002.js"></script>
    <script src="__admin__/style/bootstrap.js"></script>
    <script src="__admin__/style/jquery.js"></script>
    <!--Beyond Scripts-->
    <script src="__admin__/style/beyond.js"></script>
    <script type="text/javascript">
        $("select[name='type_id[]']").change(function(){
            var _this = $(this);
            var typeId = $(this).val();
            var opt = "<option value=''>请选择</option>";
            if(typeId){
                $.ajax({
                    type:'POST',
                    url:"{:url('admin/Attr/ajaxGetAttr')}",
                    data:{type_id:typeId},
                    dataType:'json',
                    success:function(data){
                        var attrId = _this.next('select').attr("attr_id");
                        $(data).each(function(k,v){
                            if(attrId == v.id){
                                var sel='selected="selected"';
                            }else{
                                var sel='';
                            }
                           opt += "<option "+sel+" value='"+v.id+"'>"+v.attr_name+"</option>";
                        });
                        _this.next('select').html(opt);
                    }
                });
            }else{
                $(this).next('select').html(opt);
            }
        });

        function add(o){
            var div = $(o).parent();
            if($(o).html() == '[+]'){
               var newdiv = div.clone(true);
                newdiv.find("a").html('[-]');
                div.after(newdiv); 
            }else{
                div.remove();
            }
            
        }

        $("select[name='type_id[]']").trigger("change");

    </script>


</body></html>